if not vim.g.vscode then return {} end -- don't do anything in non-vscode instances

local enabled = {}
vim.tbl_map(function(plugin) enabled[plugin] = true end, {
  -- core plugins
  "lazy.nvim",
  "AstroNvim",
  "astrocore",
  "astroui",
  "Comment.nvim",
  "nvim-autopairs",
  "nvim-treesitter",
  "nvim-ts-autotag",
  "nvim-treesitter-textobjects",
  "nvim-ts-context-commentstring",
  -- more known working
  "flash.nvim",
  "boole.nvim",
  -- "flit.nvim",
  -- "leap.nvim",
  -- "mini.ai",
  -- "mini.comment",
  "mini.surround",
  "text-case.nvim",
  "vim-textobj-entire",
  "vim-textobj-user",
  -- "vim-easy-align",
  -- "vim-repeat",
  -- "vim-sandwich",
  -- feel free to open PRs to add more support!
})

local Config = require "lazy.core.config"
-- disable plugin update checking
Config.options.checker.enabled = false
Config.options.change_detection.enabled = false
-- replace the default `cond`
Config.options.defaults.cond = function(plugin) return enabled[plugin.name] end

---@type LazySpec
local vscode = require "vscode-neovim"
return {
  -- add a few keybindings
  {
    "AstroNvim/astrocore",
    ---@type AstroCoreOpts
    opts = {
      mappings = {
        n = {
          ["<Leader>ff"] = "<Cmd>Find<CR>",
          -- ["<Leader>fw"] = "<Cmd>call VSCodeNotify('workbench.action.findInFiles')<CR>",
          ["<Leader>ls"] = "<Cmd>call VSCodeNotify('workbench.action.gotoSymbol')<CR>",
          ["]b"] = "<Cmd>Tabnext<CR>",
          ["[b"] = "<Cmd>Tabprevious<CR>",
          ["<leader>sc"] = function() vscode.action "workbench.action.showCommands" end,
          ["<leader>q"] = function() vscode.action "workbench.action.quit" end,
          ["<leader>lv"] = function() vscode.action "python.setInterpreter" end,
          ["<leader>w"] = function() vscode.action "workbench.action.files.save" end,
          ["<leader>n"] = function() vscode.action "workbench.action.files.newUntitledFile" end,
          ["<leader>fw"] = function() vscode.action "workbench.action.experimental.quickTextSearch" end,
          ["<leader>ff"] = function() vscode.action "workbench.action.quickOpen" end,
          ["<leader>fe"] = function() vscode.action "workbench.explorer.fileView.focus" end,
          ["<leader>e"] = function() vscode.action "workbench.action.toggleSidebarVisibility" end,
          ["<leader>j"] = function() vscode.action "workbench.action.togglePanel" end,
          ["<leader>th"] = function() vscode.action "workbench.action.terminal.toggleTerminal" end,
          ["<leader>fk"] = function() vscode.action "workbench.action.openGlobalKeybindings" end,
          ["<leader>c"] = function() vscode.action "workbench.action.closeActiveEditor" end,
          ["<leader>ll"] = function() vscode.action "workbench.action.reloadWindow" end,
          ["<leader>fp"] = function() vscode.action "workbench.action.openRecent" end,
          ["<leader>la"] = function() vscode.action "editor.action.quickFix" end,
          ["<leader>lf"] = function() vscode.action "editor.action.formatDocument" end,
          ["<leader>lt"] = function() vscode.action "prettier.forceFormatDocument" end,
          ["<leader>vp"] = function() vscode.action "editor.action.marker.next" end,
          ["<leader>gg"] = function() vscode.action "lazygitWrapper.open" end,
          ["<leader>sp"] = function() vscode.action "workbench.profiles.actions.switchProfile" end,
          ["<leader>rr"] = function() vscode.action "code-runner.run" end,
          ["<leader>rs"] = function() vscode.action "code-runner.stop" end,
          ["<leader>rc"] = function() vscode.action "workbench.action.closePanel" end,
          ["<leader>oc"] = function() vscode.action "workbench.output.action.clearOutput" end,
          ["<leader>tc"] = function() vscode.action "workbench.action.terminal.clear" end,
          ["<leader>xx"] = function() vscode.action "workbench.actions.view.problems" end,
          ["<leader>fc"] = function() vscode.action "problems.action.clearFilterText" end,
          ["]d"] = function() vscode.action "editor.action.marker.nextInFiles" end,
          ["[d"] = function() vscode.action "editor.action.marker.prevInFiles" end,
          ["gr"] = function() vscode.action "editor.action.referenceSearch.trigger" end,
          ["<leader>lR"] = function() vscode.action "editor.action.referenceSearch.trigger" end,
          ["<leader>lr"] = function() vscode.action "editor.action.rename" end,
          ["<leader>lh"] = function() vscode.action "editor.action.triggerParameterHints" end,
        },
      },
    },
  },
  -- disable colorscheme setting
  { "AstroNvim/astroui", opts = { colorscheme = false } },
  -- disable treesitter highlighting
  { "nvim-treesitter/nvim-treesitter", opts = { highlight = { enable = false } } },
}
